using System;
using System.Collections.Generic;
using System.Linq;
using Granite.Commons.Collections;

namespace LeadTracker.Models
{
	public class EditorCollection : ImprovedObservableCollection<EditorModel>
	{
		public EditorCollection() { }

		public EditorCollection(List<EditorModel> list) : base(list) { }
		
		public EditorCollection(IEnumerable<EditorModel> collection) : base(collection) { }

		public EditorCollection(IEnumerable<IDictionary<string, object>> table)
		{
			foreach (var item in table)
				Add(new EditorModel(item));
		}

		public EditorModel FindKey(int editorKey)
		{
			return this.FirstOrDefault(e => e.EditorKey == editorKey);
		}

		public bool Contains(int editorKey)
		{
			return this.Any(e => e.EditorKey == editorKey);
		}
	}
}

